<?php
namespace Home\Form;

use Zend\Form\Form,
    Zend\Form\Element\Captcha,
    Zend\Captcha\Image as CaptchaImage;
use Zend\Db\Adapter\AdapterInterface;

class LienheForm extends Form
{
	protected $dbAdapter;
    public function __construct(AdapterInterface $dbAdapter)
    {
		$this->setDbAdapter($dbAdapter);
        // we want to ignore the name passed
        parent::__construct('lienhe');
		
        $this->setAttribute('method', 'post');
        
		$urlcaptcha = '../data/captcha';
        $dirdata = './data';
 
                                         //pass captcha image options
        $captchaImage = new CaptchaImage(  array(
                'font' => $dirdata . '/fonts/arial.ttf',
                'width' => 250,
                'height' => 100,
                'dotNoiseLevel' => 40,
                'lineNoiseLevel' => 3)
        );
        $captchaImage->setImgDir($dirdata.'/captcha');
        $captchaImage->setImgUrl($urlcaptcha);
 
        //add captcha element...
        $this->add(array(
            'type' => 'Zend\Form\Element\Captcha',
            'name' => 'captcha',
            'options' => array(
                'label' => 'Vui lòng nhập vào kí tự captcha',
                'captcha' => $captchaImage,
            ),
			'attributes' => array(
				'id' => 'captcha',
				'required' => 'required',
                
            )
        ));
		
		$this->add(array(
            'type' => 'text',
            'name' => 'hoten',
            'options' => array(
                'label' => 'Họ tên',
               
            ),
            'attributes' => array(
				'id' => 'hoten',
				'required' => 'required',
                
            )
        ));
		$this->add(array(
            'name' => 'email',
            'attributes' => array(
				'id' => 'email',
                'type'  => 'email',
				'required' => 'required',
            ),
            'options' => array(
                'label' => 'Email',
            ),
        ));
		$this->add(array(
            'type' => 'text',
            'name' => 'tieude',
            'options' => array(
                'label' => 'Tiêu đề',
               
            ),
            'attributes' => array(
				'id' => 'tieude',
				'required' => 'required',
                
            )
        ));
		$this->add(array(
            'name' => 'noidung',
            'attributes' => array(
				'id' => 'noidung',
                'type'  => 'textarea',
				'required' => 'required',
            ),
            'options' => array(
                'label' => 'Nội dung',
            ),
        ));

        $this->add(array(
            'name' => 'submit',
            'attributes' => array(
                'type'  => 'submit',
                'value' => 'Go',
                'id' => 'submitbutton',
            ),
        ));

    }
	
	
	
	public function setDbAdapter(AdapterInterface $dbAdapter)
    {
        $this->dbAdapter = $dbAdapter;

        return $this;
    }

    public function getDbAdapter()
    {
        return $this->dbAdapter;
    }
}
